package day0308;

import java.util.Map;

public class MapDemo {

    public static void main(String[] args) {
        // 不可以修改的 Map : 不能增删改.  Map.of   Map.copyOf   Map.ofEntries
        Map map = Map.of(1, "aaaa", 2, "bbb", 3, "ccc");
//        Map.Entry entry = Map.entry(1, "Aaa");
//
//        Map map = Map.ofEntries(entry, Map.entry(2, "bbb"));

        System.out.println(map);

        System.out.println(map.size());

        // 取值
//        Object v = map.get(4);
        Object v = map.getOrDefault(2, "default");
        System.out.println(v);


        System.out.println(map.containsKey(2));
        System.out.println(map.containsKey("2"));
        System.out.println(map.containsValue("aaa"));


    }
}
